/**
 * Created with IntelliJ IDEA.
 * User: ajhin
 * Date: 1/30/14
 * Time: 7:49 AM
 * To change this template use File | Settings | File Templates.
 */
package com.societyGames.flashForms
{
import flash.display.DisplayObject;

public class HorizontalPaddedTileContainer extends HorizontalTileContainer
{
  private var _gutterWidth:Number = 0;
  private var _gutterHeight:Number = 0;

  public function set gutterWidth(value:Number):void
  {
    _gutterWidth = value;
  }

  public function get gutterWidth():Number
  {
    return this._gutterWidth;
  }

  public function set gutterHeight(value:Number):void
  {
    _gutterHeight = value;
  }

  public function get gutterHeight():Number
  {
    return this._gutterHeight;
  }

  protected override function calculateWidth():void
  {
    var totalGutterWidth:Number = (this._items.length + 1) * _gutterWidth;
    var widthLeft:Number = _desiredWidth - totalGutterWidth;
    var tileWidth:Number = widthLeft / Number(this._items.length);
    var tileX:Number = _gutterWidth;
    for each (var item:DisplayObject in this._items)
    {
      item.width = tileWidth;
      item.x = tileX;
      tileX += _gutterWidth + tileWidth;
    }
  }

  protected override function calculateHeight():void
  {
    for each (var item:DisplayObject in this._items)
    {
      item.height = this._desiredHeight - (_gutterHeight * 2);
      item.y = _gutterHeight;
    }
  }
}
}
